﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace 多协议通信平台.Common
{
    public class ValueSubtractConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (double.TryParse(value.ToString(),out double rawValue) && double.TryParse(parameter?.ToString(), out double subtractValue))
            {
                return Math.Max(0, rawValue - subtractValue); // 确保高度不为负
            }
            return value; // 回退
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
